
/**
 * es6 给函数添加了 name 属性，并且会选择合适的 name 来输出
 * 对于 get 和 set 会在名称前面添加 get 或 set
 * 对于 bind 会在前面添加 bound
 * 使用 Function 的会显示 anonymous
 */


var doSomething = function doSomethingElse() {
    // ...
};
var person = {
    get firstName() {
        return "Nicholas"
    },
    sayName: function () {
        console.log(this.name);
    }
}
console.log(doSomething.name); // "doSomethingElse"
console.log(person.sayName.name); // "sayName"
var descriptor = Object.getOwnPropertyDescriptor(person, "firstName");
console.log(descriptor.get.name); // "get firstName"

console.log(doSomething.bind().name); // "bound doSomething"
console.log((new Function()).name); // "anonymous"

let a = new Function("a", "console.log(a); return a;");
console.log(a.name); // "anonymous"

// doSomethingElse
// sayName
// get firstName
